﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using schedulelist.ORM.dao.interfaces;
using schedulelist.ORM.domain;
using NHibernate;
namespace schedulelist.ORM.dao.classes
{
    class DepartamentDAO : GenericDAO<Departament>, IDepartamentDAO
    {
        public DepartamentDAO(ISession session) : base(session) { }
        public Departament getDepartamentByName(
        string name)
        {
            var list = session.CreateSQLQuery(
            "SELECT departament.* FROM departament" +
            " WHERE departament.name='" + name + "'")
            .AddEntity("Departament", typeof(Departament))
            .List<Departament>();
            Departament dep = list[0];
            return dep;
        }

        public Departament getDepartamentById(
        int id)
        {
            var list = session.CreateSQLQuery(
            "SELECT departament.* FROM departament" +
            " WHERE departament.Id='" + id + "'")
            .AddEntity("Departament", typeof(Departament))
            .List<Departament>();
            Departament dep = list[0];
            return dep;
        }
    }
}
